/*
 * Sample of tail -f in C++
 * by RaX| <raxxx.fr@gmail.com>
 */


#include <iostream>
#include <fstream>

int
main (int argc, char *argv[])
{

  if (argc < 2)
    return EXIT_FAILURE;

  std::ifstream file (argv[1]);

  if (file.is_open ())
   {
    for (;;usleep (10))
     {
      std::string line;

      if (file.fail ())
        file.clear ();
          
      std::getline (file, line);
      if (!line.empty ())
        std::cout << line << std::endl;
     }
    file.close ();
   }

  return EXIT_SUCCESS;

}

